<!--  -->
<template>
  <div class='xgdrmima'>
       <van-nav-bar
      title="修改登入密码"
      left-text="返回"
      
      @click-left="$router.back()"
    />
    <van-form @submit="onSubmit">
  <van-field
    v-model="oldpassword"
    name="旧密码"
    label="旧密码"
    placeholder="请输入旧密码"
    :rules="[{ required: true, message: '请填旧密码' }]"
  />
  <van-field
    v-model="newpassword"
    type="password"
    name="新密码"
    label="新密码"
    placeholder="请输入新密码"
    :rules="[{ required: true, message: '请填写密码' },{pattern,message:'请填输入至少6位字母和数字的密码'}]"
  />
  <div style="margin: 16px 0;">
    <van-button size="large" block type="primary" native-type="submit">提交</van-button>
  </div>
</van-form>
  </div>
</template>

<script>
import { xigaidenglumimaqq } from "network/api.js";
import { mapMutations } from "vuex";
export default {
name:'',
  data () {
    return {
      oldpassword:'',
      newpassword:'',
      pattern:/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,}$/
    };
  },


  computed: {
    
  },


  methods: {
    ...mapMutations(["chundata"]),
    async onSubmit(){
      const {errcode,errmsg}=await xigaidenglumimaqq(this.oldpassword,this.newpassword)
      if(errcode!=0) return this.$toast(errmsg)
      this.chundata({})
      sessionStorage.clear()
      //不会留记录
      this.$router.replace('/me')
    }
  }
}

</script>
<style lang='less' scoped>
</style>